package com.bafa.front.admin;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bafa.dbcache.LeagueCache;
import com.bafa.exceptions.ErrorException;
import com.bafa.objects.PageBean;
import com.bafa.services.RetrieveServices;
import com.bafa.services.SeasonServices;

public class AddDivisionRulesServlet extends AdminServlet {

	/* (non-Javadoc)
	 * @see com.bafa.front.admin.AdminServlet#doAdminEvent(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	@Override
	public void doAdminEvent(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, ErrorException {
		
		try{
			SeasonServices.addLeagueRules(
					new Integer(request.getParameter("seasonId")), 
					new Integer(request.getParameter("divisionId")), 
					new Integer(request.getParameter("promoted")), 
					new Integer(request.getParameter("relegated")), 
					new Integer(request.getParameter("playEach")));
		
			request.setAttribute("CREATEDSEASON",RetrieveServices.getSeason(request.getParameter("seasonId")));
			request.setAttribute("TEAMS",RetrieveServices.getAllTeams());
			PageBean pageBeanTemp = (PageBean)LeagueCache.getPages().get("createseason");
			pageBean = new PageBean(pageBeanTemp);
		}catch(Exception e){
			
		}
		
	}

	
	
}
